package demo1228.pm;

public class SaleTicket implements Runnable {
        Integer num = 1;
    int tickets = 100;
    @Override
    public void run() {
        while (tickets>0){
            synchronized (num){
                if (tickets>0){
                    System.out.println(Thread.currentThread().getName()+
                            "正在售卖第"+tickets+"张票,还有"+ --tickets+"张票");
                }
            }

        }
    }
}
